# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models



class Game(models.Model):
    # 队伍
    home_team = models.CharField(max_length = 50)
    away_team = models.CharField(max_length=50)
    # 时间
    time = models.CharField(max_length = 50)
    # 举行城市
    city = models.CharField(max_length = 50)
    court = models.CharField(max_length=50)
    type = models.CharField(max_length=50)
    # 备注
    ext_info = models.CharField(max_length = 50)


class TravelSearchLog(models.Model):
    openid = models.CharField(max_length = 256)
    citys = models.CharField(max_length = 256)
    match = models.CharField(max_length = 256)
    date = models.CharField(max_length = 256)
    age = models.CharField(max_length = 256)
    gender = models.CharField(max_length = 256)

# 行程
class Travel(models.Model):
    openid = models.CharField(max_length=50)
    peer_num = models.IntegerField("同行人数")
    from_city = models.CharField("出发地", max_length=20)
    to_city = models.CharField("目的地", max_length=20)
    start_date = models.CharField("入境时间/开始时间", max_length=30)
    end_date = models.CharField("离境时间/离开时间", max_length=30)
    matches = models.CharField("观赛比赛id", max_length=256)
    vehicle = models.CharField("交通工具", max_length=20)
    vehicle_no = models.CharField("交通工具号", max_length=50)
    hotel = models.IntegerField("是否预订宾馆")
    hotel_name = models.CharField("宾馆名", max_length=200)
    travel_type = models.IntegerField("1-出入境，2-旅游")
    created_at = models.IntegerField("创建时间")


class TravelEvent(models.Model):
    openid = models.CharField(max_length=50)
    rec_openid = models.CharField(max_length=50)
    event = models.IntegerField("1-点赞，2-查看，3-约伴")
    status = models.IntegerField("1-未查看,2-查看")
    result = models.IntegerField("1- 不同意 2 同意 3-未处理")
    created_at = models.IntegerField("创建时间")


class TravelMatching(models.Model):
    openid = models.CharField(max_length=50)
    ref_openid = models.CharField(max_length=50)
    match_rate = models.IntegerField()
    created_at = models.IntegerField()
    updated_at = models.IntegerField()


# 用户
class User(models.Model):
    openid = models.CharField(max_length = 50)
    name = models.CharField(max_length = 50, blank = True)
    age = models.IntegerField()
    birth_year = models.IntegerField()
    imgurl = models.CharField('头像', max_length = 300, default = '', blank = True)
    wxname = models.CharField('昵称', max_length = 50)
    wxid = models.CharField('微信号', max_length = 50, default = '', blank = True)
    gender = models.IntegerField('性别')
    phone = models.CharField('电话', max_length = 12, default = '', blank = True)
    hashit = models.CharField('是否中签', max_length = 2)
    city = models.CharField(max_length = 20, blank = True)
    province = models.CharField(max_length = 20)
    country = models.CharField(max_length = 20)
    language = models.CharField(max_length = 20, default = 'zh_CN')
    travels = models.ManyToManyField(Travel)
    games = models.ManyToManyField(Game)
    ext_info = models.CharField(max_length = 50, blank = True)
    subscribe = models.CharField('是否关注', max_length = 2)
    description = models.CharField("个人描述", max_length=256)
    support_teams = models.CharField("支持队伍", max_length=256)
    labels = models.CharField("个人标签", max_length=256)
    support_num = models.IntegerField("点赞数量")
    address_info = models.CharField(max_length=256)


class UserUnion(models.Model):
    openid = models.CharField(max_length=50)
    unionid = models.CharField(max_length=50)
    mini_openid = models.CharField(max_length=50)


# class UserIdentifying(models.Model):
#     openid = models.CharField(max_length=50)
#     id_number = models.CharField(max_length=32)
#     phone_number = models.CharField(max_length=16)
#     real_name = models.CharField(max_length=16)
#     verify_code = models.CharField(max_length=6)
#     created_at = models.IntegerField()
#     updated_at = models.IntegerField()


# 记录
class Record(models.Model):
    wxname = models.CharField('昵称', max_length = 50)
    imgurl = models.CharField('头像', max_length = 300, default = '', blank = True)
    wxid = models.CharField('微信号', max_length = 50, default = '', blank = True)
    gender = models.IntegerField('性别')
    phone = models.CharField('电话', max_length = 12, default = '', blank = True)
    accompanyno = models.CharField('同行人数', max_length = 2, default = '1', blank = True)
    start_city = models.CharField('出发城市', max_length = 20)
    start_date = models.DateTimeField('出发日期')
    end_date = models.DateTimeField('结束日期')
    ticket_type = models.CharField('门票类型', max_length = 50)
    transfer_type = models.CharField('转让意向', max_length = 100)
    ticket_session = models.CharField('中签场次', max_length = 100, default = '', blank = True)
    ticket_arena = models.CharField('中签场馆', max_length = 100, default = '', blank = True)
    ticket_team = models.CharField('中签球队', max_length = 100, default = '', blank = True)
    ticket_team_count = models.CharField('跟队票场次', max_length = 10, default = '', blank = True)
    remark = models.CharField('备注', max_length = 300, default = '', blank = True)

# 微信群
class WXcrowd(models.Model):
    crowdid = models.CharField('id', max_length = 50)
    name = models.CharField('群名称', max_length = 50)
    imgurl = models.CharField('群url', max_length = 300)
    crowdtype = models.CharField('群类别', max_length = 50)


#advice
class Advice(models.Model):
    openid = models.CharField(max_length = 50)
    advice = models.CharField('建议',max_length=1000)

#event tracking
class Tracking(models.Model):
    url = models.CharField(max_length = 300)
    event = models.CharField(max_length = 300)
    num = models.IntegerField()


#留言
class Comment(models.Model):
    openid = models.CharField(max_length=50)
    name = models.CharField(max_length=50)
    img_url = models.CharField(max_length=255)
    messaged_openid = models.CharField(max_length=50)
    messaged_name =models.CharField(max_length=50)
    messaged_img_url = models.CharField(max_length=255)
    parentid = models.IntegerField(blank=True, null=True)
    content = models.TextField()
    status = models.IntegerField("1-未查看,2-查看")
    created_at = models.IntegerField()
    updated_at = models.IntegerField()


#player
class Player(models.Model):
    name = models.CharField(max_length=50)
    team = models.CharField(max_length=50)
    position = models.CharField(max_length=10)
    number = models.CharField(max_length=10)
    nation = models.CharField(max_length=20)
    age = models.CharField(max_length=20)
    birthday = models.CharField(max_length=20)
    height = models.CharField(max_length=20)
    weight = models.CharField(max_length=20)
    usual_foot = models.CharField(max_length=20)
    img_url = models.CharField(max_length=255)
    url = models.CharField(max_length=255)
    ext1 = models.TextField()


class UserConfig(models.Model):
    openid = models.CharField(max_length=50)
    config = models.TextField()


class PayDeal(models.Model):
    trade_id = models.CharField(max_length=50)
    transaction_id = models.CharField(max_length=32)
    prepay_id = models.CharField(max_length=64)
    order_id = models.CharField(max_length=50)
    openid = models.CharField(max_length=50)
    request_amount = models.DecimalField(max_digits=11, decimal_places=2)
    receive_amount = models.DecimalField(max_digits=11, decimal_places=2)
    pay_status = models.IntegerField()
    error_message = models.CharField(max_length=256)
    type = models.IntegerField()
    operate_status = models.IntegerField()
    time_end = models.CharField(max_length=14)
    created_at = models.IntegerField()
    updated_at = models.IntegerField()


class Spu(models.Model):
    spu_code = models.IntegerField()
    spu_name = models.CharField(max_length=256)
    spu_image = models.CharField(max_length=256)
    spu_description = models.CharField(max_length=1024)
    spu_ext_properties = models.CharField(max_length=256)
    specification_name = models.CharField(max_length=1024)
    category_id = models.CharField(max_length=11)
    category_name = models.CharField(max_length=64)
    supply = models.CharField(max_length=64)
    order = models.IntegerField()
    is_hot = models.IntegerField()
    sale_volume = models.IntegerField()
    status = models.IntegerField()
    created_at = models.IntegerField()
    updated_at = models.IntegerField()
    desc_imgs = models.TextField()


class Sku(models.Model):
    sku_code = models.IntegerField()
    sku_name = models.CharField(max_length=256)
    spu_code = models.IntegerField()
    sku_images = models.CharField(max_length=1024)
    sku_specification = models.CharField(max_length=1024)
    inventory_num = models.IntegerField()#库存数量
    sale_unit = models.IntegerField()
    sale_unit_name = models.CharField(max_length=16)
    origin_price = models.DecimalField(max_digits=11, decimal_places=2)
    price = models.DecimalField(max_digits=11, decimal_places=2)
    status = models.IntegerField()
    created_at = models.IntegerField()
    updated_at = models.IntegerField()


class OrderHead(models.Model):
    order_code = models.IntegerField()
    order_status = models.IntegerField()
    openid = models.CharField(max_length=50)
    address = models.CharField(max_length=512)
    total_qty = models.IntegerField()
    total_amount = models.DecimalField(max_digits=11, decimal_places=2)
    express_type = models.IntegerField()        # 邮寄方式 1-加邮费 2- 到付
    express_company = models.CharField(max_length=64)
    express_code = models.CharField(max_length=64)
    order_time = models.IntegerField() 			# 下单时间
    cancel_time = models.IntegerField()         # 取消时间
    pay_status = models.IntegerField()          # 支付状态
    refund_status = models.IntegerField()       # 退款状态
    status = models.IntegerField()
    created_at = models.IntegerField()
    updated_at = models.IntegerField()


class OrderDetail(models.Model):
    order_code = models.IntegerField()
    sku_code = models.IntegerField()
    sku_name = models.CharField(max_length=64)
    sku_specification = models.CharField(max_length=1024)
    sku_image = models.CharField(max_length=1024)
    origin_price = models.DecimalField(max_digits=11, decimal_places=2)
    price = models.DecimalField(max_digits=11, decimal_places=2)
    qty = models.IntegerField()
    is_mark = models.IntegerField()
    mark_msg = models.CharField(max_length=64)
    status = models.IntegerField()
    created_at = models.IntegerField()
    updated_at = models.IntegerField()



class ShoppingCart(models.Model):
    openid = models.CharField(max_length=50)
    sku_code = models.IntegerField()
    sku_name = models.CharField(max_length=256)
    sku_image = models.CharField(max_length=1024)
    sku_specification = models.CharField(max_length=1024)
    origin_price = models.DecimalField(max_digits=11, decimal_places=2)
    add_price = models.DecimalField(max_digits=11, decimal_places=2) 	# 加车时刻价格
    qty = models.IntegerField()#该sku的数量
    created_at = models.IntegerField()
    updated_at = models.IntegerField()



class LotteryCode(models.Model):
    openid = models.CharField(max_length=50)
    activity = models.CharField('活动场次',max_length=20)
    code = models.CharField('抽奖号',max_length=30)
    num = models.IntegerField('抽奖次数',default=0)

class Article(models.Model):
    name = models.CharField(max_length=64)
    content = models.TextField()
    date = models.CharField(max_length=16)
    survey = models.CharField(max_length=1024)
    survey_image = models.CharField(max_length=1024)
    hits = models.IntegerField()
    category_name = models.CharField(max_length=64)



class GameType(models.Model):
    name = models.CharField(max_length=100)





'''
class Notifaction(models.Model):
    title = models.CharField('标题',max_length=125)
'''
